package com.yinhe.music.yhmusic.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yinhe.music.common.GlideHelper.GlideHelper;
import com.yinhe.music.common.utils.KeywordUtil;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.SingerList;

import java.util.List;

/**
 *
 * @author hasee
 * @date 2017/8/15
 */

public class SingerListAdapter extends BaseQuickAdapter<SingerList, BaseViewHolder> {
    private String key;

    public SingerListAdapter(@Nullable List<SingerList> data) {
        super(R.layout.fragment_follow_item, data);
    }

    public SingerListAdapter(@Nullable List<SingerList> data,String key) {
        super(R.layout.fragment_follow_item, data);
        this.key = key;
    }

    public void setSearchKey(String key) {
        this.key = key;
    }

    @Override
    protected void convert(BaseViewHolder helper, SingerList item) {
        helper.setText(R.id.singer_name,item.getSingerName());
        ImageView image = helper.getView(R.id.singer_image);
        GlideHelper.setImageResource(image,item.getImage(),R.drawable.ic_default_singer);
        if (key != null) {
            helper.setText(
                    R.id.singer_name,
                    KeywordUtil.matcherSearchTitle(Color.parseColor("#1d89ff"),
                    item.getSingerName(),
                    key));
        }
    }
}
